package com.atguigu.flink.chapter5.transform;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2020/12/19 14:56
 */
public class Flink09_Transform_Union {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        DataStreamSource<Integer> s1 = env.fromElements(1, 2, 3, 4, 5);
        DataStreamSource<Integer> s2 = env.fromElements(10, 20, 30, 40);
        DataStream<Integer> s12 = s1.union(s2);

        s12.print();


        env.execute();
    }
}
/*
connect 和union的区别:
1. connect只能合并两个, union没有限制
2. connect合并到两个流的数据类型可以不一致, union必须一致
3. connect合并的流没有真正的合并到一起, 内部还是分开.
 */
